Added an example of how to use GDK_MODIFIER_MASK to test for modifier keys
authorFederico Mena Quintero <federico@ximian.com>
Mon, 16 Feb 2004 18:12:43 +0000 (18:12 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Mon, 16 Feb 2004 18:12:43 +0000 (18:12 +0000)
2004-02-16  Federico Mena Quintero  <federico@ximian.com>

* gdk/tmpl/windows.sgml: Added an example of how to use
GDK_MODIFIER_MASK to test for modifier keys correctly.

docs/reference/ChangeLog
docs/reference/gdk/tmpl/windows.sgml

index 67b5dddf2c8ed0ee326fd45024860b447c8a4f8a..9478a875ee6fd215e6ef91eae25c09b784b0c6fc 100644 (file)
@@ -1,3 +1,8 @@
+2004-02-16  Federico Mena Quintero  <federico@ximian.com>
+
+       * gdk/tmpl/windows.sgml: Added an example of how to use
+       GDK_MODIFIER_MASK to test for modifier keys correctly.
+
 Sun Feb 15 23:51:08 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/tmpl/gtkcomboboxentry.sgml: 
index cbe2ca93b42554b41b6d0344a17f419fa9da9110..de2d8aeb570c2c7ea562d6e2d1e2cc5c943b3405 100644 (file)
@@ -1126,7 +1126,35 @@ Like the X Window System, GDK supports 8 modifier keys and 5 mouse buttons.
 @GDK_BUTTON5_MASK: the fifth mouse button.
 @GDK_RELEASE_MASK: not used in GDK itself. GTK+ uses it to differentiate 
   between (keyval, modifiers) pairs from key press and release events.
-@GDK_MODIFIER_MASK: 
+@GDK_MODIFIER_MASK: Mask that can be used to see if modifier keys are
+  pressed.  See <xref linkend="keys-with-modifiers"/> for an example
+  of how to use this mask.
+
+  <example id="keys-with-modifiers">
+    <title>Testing for keys with modifiers</title>
+
+    <para>
+      The following code shows how you should use GDK_MODIFIER_MASK to
+      test for
+      <keycombo><keycap>Control</keycap><keycap>F10</keycap></keycombo>
+      being pressed.
+    </para>
+
+    <programlisting>
+static gboolean
+my_widget_key_press_handler (GtkWidget *widget, GdkEventKey *event)
+{
+  if (event-&gt;keysym == GDK_F10
+      &amp;&amp; (event-&gt;state &amp;&amp; GDK_MODIFIER_MASK) == GDK_CONTROL_MASK)
+    {
+      g_print ("Control-F10 was pressed\n");
+      return TRUE;
+    }
+
+  return FALSE;
+}
+    </programlisting>
+  </example>
 
 <!-- ##### FUNCTION gdk_window_get_parent ##### -->
 <para>
@@ -1340,3 +1368,9 @@ Applications should never have any reason to use this facility
 @Returns: 
 
 
+<!--
+Local variables:
+mode: sgml
+sgml-parent-document: ("../gdk-docs.sgml" "book" "refsect2" "")
+End:
+-->